home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Graphics Programming (2nd Edition) / Visual Basic Graphics Programming 2nd Edition.iso / Src / Ch10 / Tile.frm (.txt) < prev    next >
Visual Basic Form  |  1999-06-09  |  9KB  |  309 lines

  1. VERSION 5.00
  2. Begin VB.Form frmTile 
  3.    Caption         =   "Tile"
  4.    ClientHeight    =   5490
  5.    ClientLeft      =   1740
  6.    ClientTop       =   900
  7.    ClientWidth     =   6870
  8.    LinkTopic       =   "Form1"
  9.    PaletteMode     =   1  'UseZOrder
  10.    ScaleHeight     =   5490
  11.    ScaleWidth      =   6870
  12.    Begin VB.PictureBox picCanvas 
  13.       AutoRedraw      =   -1  'True
  14.       Height          =   4335
  15.       Left            =   3000
  16.       ScaleHeight     =   285
  17.       ScaleMode       =   3  'Pixel
  18.       ScaleWidth      =   285
  19.       TabIndex        =   0
  20.       Top             =   120
  21.       Width           =   4335
  22.    End
  23.    Begin VB.Image imgTile 
  24.       Height          =   945
  25.       Index           =   30
  26.       Left            =   1560
  27.       Picture         =   "Tile.frx":0000
  28.       Top             =   4440
  29.       Width           =   945
  30.    End
  31.    Begin VB.Image imgTile 
  32.       Height          =   945
  33.       Index           =   28
  34.       Left            =   120
  35.       Picture         =   "Tile.frx":0242
  36.       Top             =   4440
  37.       Width           =   945
  38.    End
  39.    Begin VB.Image imgTile 
  40.       Height          =   600
  41.       Index           =   27
  42.       Left            =   2280
  43.       Picture         =   "Tile.frx":31C4
  44.       Top             =   3720
  45.       Width           =   600
  46.    End
  47.    Begin VB.Image imgTile 
  48.       Height          =   600
  49.       Index           =   26
  50.       Left            =   1560
  51.       Picture         =   "Tile.frx":334E
  52.       Top             =   3720
  53.       Width           =   600
  54.    End
  55.    Begin VB.Image imgTile 
  56.       Height          =   600
  57.       Index           =   25
  58.       Left            =   840
  59.       Picture         =   "Tile.frx":34D8
  60.       Top             =   3720
  61.       Width           =   600
  62.    End
  63.    Begin VB.Image imgTile 
  64.       Height          =   600
  65.       Index           =   24
  66.       Left            =   120
  67.       Picture         =   "Tile.frx":47DA
  68.       Top             =   3720
  69.       Width           =   600
  70.    End
  71.    Begin VB.Image imgTile 
  72.       Height          =   600
  73.       Index           =   23
  74.       Left            =   2280
  75.       Picture         =   "Tile.frx":4B7C
  76.       Top             =   3000
  77.       Width           =   600
  78.    End
  79.    Begin VB.Image imgTile 
  80.       Height          =   480
  81.       Index           =   22
  82.       Left            =   1560
  83.       Picture         =   "Tile.frx":4D06
  84.       Top             =   3000
  85.       Width           =   480
  86.    End
  87.    Begin VB.Image imgTile 
  88.       Height          =   600
  89.       Index           =   21
  90.       Left            =   840
  91.       Picture         =   "Tile.frx":4DD0
  92.       Top             =   3000
  93.       Width           =   600
  94.    End
  95.    Begin VB.Image imgTile 
  96.       Height          =   480
  97.       Index           =   20
  98.       Left            =   120
  99.       Picture         =   "Tile.frx":60D2
  100.       Top             =   3000
  101.       Width           =   480
  102.    End
  103.    Begin VB.Image imgTile 
  104.       Height          =   480
  105.       Index           =   19
  106.       Left            =   2280
  107.       Picture         =   "Tile.frx":6D14
  108.       Top             =   2400
  109.       Width           =   480
  110.    End
  111.    Begin VB.Image imgTile 
  112.       Height          =   480
  113.       Index           =   18
  114.       Left            =   1560
  115.       Picture         =   "Tile.frx":6DDE
  116.       Top             =   2400
  117.       Width           =   480
  118.    End
  119.    Begin VB.Image imgTile 
  120.       Height          =   480
  121.       Index           =   17
  122.       Left            =   840
  123.       Picture         =   "Tile.frx":6EA8
  124.       Top             =   2400
  125.       Width           =   480
  126.    End
  127.    Begin VB.Image imgTile 
  128.       Height          =   480
  129.       Index           =   16
  130.       Left            =   120
  131.       Picture         =   "Tile.frx":7AEA
  132.       Top             =   2400
  133.       Width           =   480
  134.    End
  135.    Begin VB.Image imgTile 
  136.       Height          =   420
  137.       Index           =   15
  138.       Left            =   2280
  139.       Picture         =   "Tile.frx":872C
  140.       Top             =   120
  141.       Width           =   420
  142.    End
  143.    Begin VB.Image imgTile 
  144.       Height          =   420
  145.       Index           =   14
  146.       Left            =   1560
  147.       Picture         =   "Tile.frx":87E6
  148.       Top             =   120
  149.       Width           =   360
  150.    End
  151.    Begin VB.Image imgTile 
  152.       Height          =   420
  153.       Index           =   13
  154.       Left            =   840
  155.       Picture         =   "Tile.frx":88A0
  156.       Top             =   120
  157.       Width           =   420
  158.    End
  159.    Begin VB.Image imgTile 
  160.       Height          =   420
  161.       Index           =   12
  162.       Left            =   120
  163.       Picture         =   "Tile.frx":9212
  164.       Top             =   120
  165.       Width           =   360
  166.    End
  167.    Begin VB.Image imgTile 
  168.       Height          =   450
  169.       Index           =   11
  170.       Left            =   2280
  171.       Picture         =   "Tile.frx":9A34
  172.       Top             =   1800
  173.       Width           =   450
  174.    End
  175.    Begin VB.Image imgTile 
  176.       Height          =   480
  177.       Index           =   10
  178.       Left            =   1560
  179.       Picture         =   "Tile.frx":9AF6
  180.       Top             =   1800
  181.       Width           =   480
  182.    End
  183.    Begin VB.Image imgTile 
  184.       Height          =   450
  185.       Index           =   9
  186.       Left            =   840
  187.       Picture         =   "Tile.frx":9BC0
  188.       Top             =   1800
  189.       Width           =   450
  190.    End
  191.    Begin VB.Image imgTile 
  192.       Height          =   480
  193.       Index           =   8
  194.       Left            =   120
  195.       Picture         =   "Tile.frx":A6CA
  196.       Top             =   1800
  197.       Width           =   480
  198.    End
  199.    Begin VB.Image imgTile 
  200.       Height          =   480
  201.       Index           =   7
  202.       Left            =   2280
  203.       Picture         =   "Tile.frx":B30C
  204.       Top             =   1200
  205.       Width           =   480
  206.    End
  207.    Begin VB.Image imgTile 
  208.       Height          =   480
  209.       Index           =   6
  210.       Left            =   1560
  211.       Picture         =   "Tile.frx":B3D6
  212.       Top             =   1200
  213.       Width           =   480
  214.    End
  215.    Begin VB.Image imgTile 
  216.       Height          =   480
  217.       Index           =   5
  218.       Left            =   840
  219.       Picture         =   "Tile.frx":B4A0
  220.       Top             =   1200
  221.       Width           =   480
  222.    End
  223.    Begin VB.Image imgTile 
  224.       Height          =   480
  225.       Index           =   4
  226.       Left            =   120
  227.       Picture         =   "Tile.frx":C0E2
  228.       Top             =   1200
  229.       Width           =   480
  230.    End
  231.    Begin VB.Image imgTile 
  232.       Height          =   480
  233.       Index           =   3
  234.       Left            =   2280
  235.       Picture         =   "Tile.frx":CD24
  236.       Top             =   600
  237.       Width           =   480
  238.    End
  239.    Begin VB.Image imgTile 
  240.       Height          =   480
  241.       Index           =   2
  242.       Left            =   1560
  243.       Picture         =   "Tile.frx":CDEE
  244.       Top             =   600
  245.       Width           =   480
  246.    End
  247.    Begin VB.Image imgTile 
  248.       Height          =   480
  249.       Index           =   1
  250.       Left            =   840
  251.       Picture         =   "Tile.frx":CEB8
  252.       Top             =   600
  253.       Width           =   480
  254.    End
  255.    Begin VB.Image imgTile 
  256.       Height          =   480
  257.       Index           =   0
  258.       Left            =   120
  259.       Picture         =   "Tile.frx":DAFA
  260.       Top             =   600
  261.       Width           =   480
  262.    End
  263. Attribute VB_Name = "frmTile"
  264. Attribute VB_GlobalNameSpace = False
  265. Attribute VB_Creatable = False
  266. Attribute VB_PredeclaredId = True
  267. Attribute VB_Exposed = False
  268. Option Explicit
  269. Private TileChoice As Integer
  270. ' Tile a PictureBox with the picture in an Image control.
  271. Private Sub TilePicture(ByVal pic As PictureBox, ByVal tile_image As Image)
  272. Dim wid As Integer
  273. Dim hgt As Integer
  274. Dim rows As Integer
  275. Dim cols As Integer
  276. Dim r As Integer
  277. Dim c As Integer
  278. Dim x As Integer
  279. Dim y As Integer
  280.     pic.Cls     ' Clear the picture box.
  281.     wid = ScaleX(tile_image.Width, tile_image.Parent.ScaleMode, pic.ScaleMode)
  282.     hgt = ScaleY(tile_image.Height, tile_image.Parent.ScaleMode, pic.ScaleMode)
  283.     ' See how many rows and columns we will need.
  284.     cols = Int(pic.ScaleWidth / wid + 1)
  285.     rows = Int(pic.ScaleHeight / hgt + 1)
  286.     ' Copy the tile.
  287.     y = 0
  288.     For r = 1 To rows
  289.         x = 0
  290.         For c = 1 To cols
  291.             pic.PaintPicture tile_image.Picture, x, y
  292.             x = x + wid
  293.         Next c
  294.         y = y + hgt
  295.     Next r
  296. End Sub
  297. ' Tile the form.
  298. Private Sub Form_Resize()
  299. Dim wid As Single
  300.     wid = ScaleWidth - picCanvas.Left
  301.     If wid < 120 Then wid = 120
  302.     picCanvas.Move picCanvas.Left, 0, wid, ScaleHeight
  303.     TilePicture picCanvas, imgTile(TileChoice)
  304. End Sub
  305. Private Sub imgTile_Click(Index As Integer)
  306.     TileChoice = Index
  307.     TilePicture picCanvas, imgTile(Index)
  308. End Sub
  309.